package main

import "fmt"

// 动态规划求存在多个字符串 s,t字符串

func main()  {
	var s,t  ="babgbag","bag"
	tlen,slen := len(t),len(s)

	var jz [][]int
	jz = make([][]int,slen+1)
	for i :=0;i < slen+1;i++{
		jz[i] = make([]int,tlen+1)
		jz[i][tlen] = 1
	}
	for i:=0;i<=tlen;i++{
		jz[slen][i] = 0
	}
	jz[slen][tlen] = 1

	for i := slen-1;i >=0;i-- {
		for j:= tlen-1; j>=0;j--{
			if s[i] == t[j] {
				jz[i][j] = jz[i+1][j+1] + jz[i+1][j]
			}else {
				jz[i][j] = jz[i+1][j]
			}
		}
	}
	fmt.Println(t)
	fmt.Println(jz)
	fmt.Println(jz[0][0])

}